﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SES.CMS.BL;
using SES.CMS.DO;
namespace SES.CMS.AdminCP
{
    public partial class ListProductCategory : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            tlCategory.DataSource = new cmsProductCategoryBL().SelectAll();
            tlCategory.DataBind();
            tlCategory.ExpandToLevel(3);
        }
        protected void lbtnAdd_Click(object sender, EventArgs e)
        {
            Response.Redirect("ProductCategory.aspx");
        }
        protected void tlCategory_StartNodeEditing(object sender, DevExpress.Web.ASPxTreeList.TreeListNodeEditingEventArgs e)
        {
            int id = 0;
            if (int.TryParse(tlCategory.EditingNodeKey, out id))
            {
                Response.Redirect("ProductCategory.aspx?Pid=" + id.ToString());
            }
        }
        protected void tlCategory_NodeDeleted(object sender, DevExpress.Web.Data.ASPxDataDeletedEventArgs e)
        {
            new cmsProductCategoryBL().Delete(new cmsProductCategoryDO() { ProductCategoryID = int.Parse(tlCategory.FocusedNode.Key) });
            Response.Redirect("ListProductCategory.aspx");
        }
    }
}